package com.dao;


import com.domain.Department;
import com.utils.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class DepartmentDao {
    //创建jdbcTemplate对象
    private JdbcTemplate jdbcTemplate = new JdbcTemplate(JDBCUtils.getDataSource());

    //查询方法,查询所有
    public List<Department> findAllDepartment() {
        //SQl
        String sql = "select * from department";
        //new BeanPropertyRowMapper<>(Department.class)进行查询
        List<Department> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Department.class));

        return list;
    }

}
